<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/commons/taglibs.jsp" %>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>作品(名家作品)基本信息修改</title>
<link href="../style/css_member.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/common.js"></script>
<script src="../js/artDialog.js?skin=gray"></script>
<script src="../js/artDialog.iframeTools.js"></script>
<script type="text/javascript" src="../js/jquery-1.3.2.js"></script>

<script type="text/javascript">
$(function(){
	$("#paintingLink").click(function(){
		var s_Id = 2;
		if(checkChooseSharp()){
			s_Id = $("input[name='painting.sharpInfo.id']:checked").val();
		}else{
			alert("请先选择画框形状");
			return false;
		}
		art.dialog.open('${ctx}/fileUpload!uploadPrepare.do?imgType=painting&sharpId='+s_Id,{title:'上传作品图片',width:800,height:550},false);
    });
});

function init(){
	choosePaintType('${painting.sharpInfo.id}');
}

	/************  提交表单 ******************/
	function checkForm() {

		var picImage = $("#picImage").val();
		if( picImage == "" ){
			alert("请上传作品图片。");
			return false;
		}
		
		var title = $.trim($("#title").val());
		if (title == "") {
			$("#title").focus();
			alert("请填写作品名称。");
			return false;
		}

		if (window.confirm("确认提交？")) {
			$.ajax({
				type:'POST',
				url:'${ctx }/painting/modify.do',
				async : false, //ajax同步
				data:$("#publishPaintingForm").serialize(),//序列化表单里所有的内容
				success: function(data){
					if(data == '0000'){
						alert("作品修改成功！");
						var win = art.dialog.open.origin;//来源页面
						win.location.reload();
						return false;
					}else{
						alert("作品修改失败！");
						return false;
					}
				}
			});
		}
	}

</script>
</head>

<body onload="init();"  style="background: #fff">

<form action="${ctx }/painting/modify.do" method="post" id="publishPaintingForm" name="publishPaintingForm" enctype="multipart/form-data">
<table width="800" border="0" align="center" cellpadding="0" cellspacing="0" style="background: #ffffff;">
      <tr>
        <td colspan="3" class="bt14A" align="center">修改作品资料</td>
      </tr>
      <tr>
        <td class="bt14A" align="right"><span class="style20">* </span>作品名称：</td>
        <td class="bt14A"><input name="painting.title" type="text" size="20" id="title" maxlength="40" value="${painting.title}"></td>
        <td width="360" rowspan="6" valign="top">
	          <table width="360" height="384"  border="0" align="center" cellpadding="0" style="vertical-align: top;">
	            <tr>
	              <td bgcolor="#FFFFFF" align="center">
	              	<div id="photoTd" style="width: 200px;height: 300px;border: 1px solid #CCCCCC;">
	              			<img src="${painting.middleImageApath }" />
	              	</div>
	              </td>
	            </tr>
	          </table>
          </td>
      </tr>
      <tr>
        <td class="bt14A" align="right"><span class="style20">*</span> 画框形状：</td>
        <td class="bt14A">
	      	 <c:forEach items="${sharpInfoList}" var="sharpInfo"  varStatus="status">
				       <input onclick="choosePaintType('${sharpInfo.id }')" type="radio" name="painting.sharpInfo.id" value="${sharpInfo.id }" <c:if test="${ sharpInfo.id == painting.sharpInfo.id}">checked</c:if>/>${sharpInfo.name }
             </c:forEach>      
	      </td>
     </tr>
      <tr>
        <td class="bt14A" align="right"><span class="style20">*</span> 上传作品：</td>
        <td class="bt14A"><span class="style18">
        	  	<a id="paintingLink" style="cursor: pointer;color: red">上传</a>
        	  </span>
      </tr>
      <tr>
        <td width="160"> <input name="painting.painter.id" type="hidden" size="10"  id="painter" value="${painting.painter.id }"></td>
        <td style="padding: 15px 0px 20px 5px;"><img src="../images/an24.gif"  style="cursor: pointer ;border: 0"  width="114" height="31"  onclick="checkForm()"> 
                <!-- 隐藏域  begin  -->
	                <input name="painting.id" type="hidden"  id="painting_id" value="${painting.id }">
	                <input name="painting.imageInfo.id" type="hidden"  id="picImage" value="${painting.imageInfo.id }">
                <!-- 隐藏域 end  -->
	     </td>
      </tr>
</table>
</form>

</body>
</html>